#pragma once
 
#include <memory>
#include <string>
#include <map>

#include "InputHandler.h"
#include "Simulation.h"

#include "Ogre.h"
#include "OgreWindowEventUtilities.h"

using namespace Ogre;

class OgreEngineManager :
 public WindowEventListener,
 public FrameListener
{
protected:
	/// OGRE Root
	Root			*root;
	/// Default OGRE Camera
	Camera			*genericCamera;
	/// OGRE RenderWIndow
	RenderWindow	*window;
	/// Scene Manager
	SceneManager	*sceneMgr;
	/// Simulation Manager
	Simulation		*sim;
	/// Input Handler
	InputHandler	*input;
	
	//constructor
	OgreEngineManager();
	//destructor
	~OgreEngineManager();
public:
	/**
	singleton access
	@return The single instance of this class
	*/
	static OgreEngineManager &Instance()
	{
		static OgreEngineManager instance;
		return instance;
	}

	//initialise the engine
	bool Startup();	
	//destroy the engine
	void Shutdown();
	//create a basic scene
	void CreateScene();

	bool frameStarted(const FrameEvent &evt);
	bool frameEnded(const FrameEvent &evt);

	/**
	@return The render window
	*/
	RenderWindow *GetRenderWindow() const
	{
		return window;
	}
	
	Root *GetRoot() const
	{
		return root;
	}
	
	Simulation *GetSimulation() const
	{
		return sim;
	}
	
	InputHandler *GetInput() const
	{
		return input;
	}

	SimulationState GetState() const
	{
		return sim->getCurrentState();
	}
};